package com.demo.service;

import com.demo.pojo.Dept;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;

/**
 * @author chenyuan
 * @date 2020/10/10 9:32
 */

/**
 * @FeignClient 标注这是一个微服务，可以被调用
 *
 * value ： 微服务的名字
 * fallbackFactory : 处理失败回调的类
 */
@Component
@FeignClient(value = "SpringCloud-02-provider",fallbackFactory = DeptClientServiceFallback.class)
public interface DeptClientService {
    /**增加
     * @param dept
     * @return
     */
    @PostMapping("/addDept")
    public boolean addDept(Dept dept);

    /** 按照 id 查询
     * @param id
     * @return
     */
    @GetMapping("/queryDeptById/{id}")
    public Dept queryDeptById(@PathVariable("id")Long id);

    /** 查询所有
     * @return
     */
    @GetMapping("/queryDepts")
    public List<Dept> queryDepts();
}
